package mysql

import "gorm.io/gorm"

type Good struct {
	gorm.Model
	GoodsId int `gorm:"type:int(11);not null;index:ip_idx"`
	UserId  int `gorm:"type:int(11);not null;"`
	Num     int `gorm:"type:int(11);not null;"`
	Stock   int `gorm:"type:int(11);not null;"`
}

type Cart struct {
	gorm.Model
	GoodsId   int    `gorm:"type:int(11);not null;index:ip_idx"`
	UserId    int    `gorm:"type:int(11);not null;"`
	Num       int    `gorm:"type:int(11);not null;"`
	Stock     int    `gorm:"type:int(11);not null;"`
	CartTitle string `gorm:"type:varchar(50);not null;"`
	CartCover string `gorm:"type:varchar(50);not null;"`
}

func (g *Good) GoodsFind(GoodsId int) error {
	return DB.Debug().Where("goods_id = ?", GoodsId).Limit(1).Find(&g).Error
}
